package yun.service;

import java.util.List;

class SequenceRepeatPlaylist<E> extends SequencePlaylist<E> {
	SequenceRepeatPlaylist(int index, List<E> list) {
		super(index, list);
	}

	@Override
	public boolean hasNext() {
		return true;
	}

	@Override
	public boolean hasPrevious() {
		return true;
	}

	@Override
	public E next() {
		if (hasNext() && !hasItem(getIndex() + 1)) {
			setIndex(0);
			return current();
		}
		return super.next();
	}

	@Override
	public E prev() {
		if (hasPrevious() && !hasItem(getIndex() - 1)) {
			setIndex(size() - 1);
			return current();
		}
		return super.prev();
	}
}